package com.lz.football.module.guess
{
	import com.common.utils.Reflection;
	import com.liangzhong.model.footballLottery.vo.GuessVo;
	import com.lz.football.module.base.IComponent;
	
	import flash.display.MovieClip;
	import flash.display.SimpleButton;
	import flash.events.Event;
	import flash.events.MouseEvent;
	import flash.text.TextField;
	
	import lz.controls.LButton;
	import lz.controls.LItem;

	/**
	 *竞猜内容item 
	 * @author lake
	 * 
	 */	
	public class FbLotteryItem extends LItem implements IComponent
	{
		/**
		 * 详情
		 */		
		private var detailBtn	:LButton;
		/**
		 *状态标识 
		 */		
		private var flagMc		:MovieClip;
		/**
		 * 时间
		 */		
		private var txtTime	:TextField;
		/**
		 * 标题
		 */		
		private var txtTitle	:TextField;
		
		public function FbLotteryItem()
		{
			super();
		}
		/**
		 *设置获取数据 
		 * @param value
		 * 
		 */		
		override public function set data(value :*):void
		{
			_data = value;
			var guessVo :GuessVo = _data;
			txtTitle.htmlText = "" + guessVo.descplay;
			txtTime.htmlText = "截止时间:" + guessVo.endDateStr;
			flagMc.gotoAndStop(guessVo.status_1);
		}
		override public function get data():*
		{
			return _data;
		}
		/**
		 *初始化 
		 * @param view
		 * 
		 */		
		public function initUI(view:Object=null):void
		{
			_symbolSkin = Reflection.createInstance("com.lz.res.fbLottery.MainItemSKin");
			detailBtn = new LButton(_symbolSkin.detailBtn);
			detailBtn.enable = true;
			detailBtn.buttonMode = true;
			flagMc = _symbolSkin.flagMc;
			txtTime = _symbolSkin.txtTime;
			txtTitle = _symbolSkin.txtTitle;
			txtTime.htmlText = "";
			txtTitle.htmlText = "";
			this.addChild(_symbolSkin);
			addEvtListener();
		}
		/**
		 *添加事件 
		 * 
		 */		
		public function addEvtListener():void
		{
			detailBtn.addEventListener(MouseEvent.CLICK,onDetailHandler);
		}
		/**
		 *点击详情 
		 * @param e
		 * 
		 */		
		private function onDetailHandler(e :MouseEvent):void
		{
			this.dispatchEvent(new Event("betResultDetail",true));
		}
		/**
		 *删除事件 
		 * 
		 */		
		public function removeEvtListener():void
		{
			detailBtn.removeEventListener(MouseEvent.CLICK,onDetailHandler);
		}
		/**
		 *销毁 
		 * 
		 */		
		public function destroyView():void
		{
			removeEvtListener();
			detailBtn.enable = false;
			detailBtn = null;
			_symbolSkin = null;
		}
	}
}